﻿using Furion.DependencyInjection;
using Furion.FriendlyException;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;

namespace Admin.Web.Core.Handlers
{
    public class LogExceptionHandler : IGlobalExceptionHandler, ISingleton
    {
        readonly ILogger _logger;
        public LogExceptionHandler(ILogger<LogExceptionHandler> logger)
        {
            _logger = logger;
        }
        public Task OnExceptionAsync(ExceptionContext context)
        {
            Exception ex = context.Exception;
            _logger.LogError(ex.Message);

            return Task.CompletedTask;
        }
    }
}
